package com.atguigu.rabbitmq.two;

import com.atguigu.rabbitmq.utils.RabbitMqUtils;
import com.rabbitmq.client.Channel;

/**
 * ClassName: Work01
 * Description: 这是一个工作线程（相当于之前消费者）
 * Date: 2023/04/27 PM 3:01:36
 * <p>
 * project: atguigu-rabbitmq
 * package: com.atguigu.rabbitmq.two
 * email: 1085844536@qq.com
 * version:
 *
 * @author WangGuojian
 */
public class Work01 {

    /**
     * 队列名称
     */
    public static final String QUEUE_NAME = "hello";

    /**
     * 接收消息
     */
    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMqUtils.getChannel();

        System.out.println(Thread.currentThread().getId() + "等待接收消息...");
        channel.basicConsume(QUEUE_NAME, true, (consumeTask, message) -> {
            System.out.println("接收到的消息：" + new String(message.getBody()));
        }, consumerTag -> System.out.println("消费者取消消费接口回调逻辑"));
    }
}
